﻿namespace System;

public static class DateTimeExtension
{
    public static string Format(this DateTime dateTime, string format)
    {
        if (dateTime == DateTime.MinValue) return null;

        return dateTime.ToString(format);
    }
    public static string Format(this DateTime? dateTime, string format)
    {
        if (dateTime == null) return null;

        return dateTime.Value.Format(format);
    }
    public static int DifferenceDays(this DateTime startDate, DateTime endDate)
    {
        TimeSpan difference = endDate - startDate;

        // 获取天数  
        int daysDifference = difference.Days;

        return daysDifference;
    }
}
